export const toast = ({ title = '数据加载中', icon = 'none', duration = 2000, mask = true } = {}) => {
  wx.showToast({
    title,
    icon,
    duration,
    mask
  })
}

export const modal = (options = {}) => {
  const defaultOpt = {
    title: '提示',
    content: '你确定要执行此操作吗',
    confirmColor: '#f3514f'
  }
  const newOpt = { ...defaultOpt, ...options }
  return new Promise((resolve) => {
    wx.showModal({
      ...newOpt,
      complete: ({ confirm, cancel }) => {
        if (confirm) {
          resolve(true)
        } else {
          resolve(false)
        }
      }
    })
  })
}
